import java.util.Scanner;
public class Test {

    public static void main1(String[] args) {

                String input = "Hello123World456";
                int digitCount = 0;
                int lowerCaseCount = 0;
                int upperCaseCount = 0;

                for (int i = 0; i < input.length(); i++) {
                    char ch = input.charAt(i);
                    if (Character.isDigit(ch)) {
                        digitCount++;
                    } else if (Character.isLowerCase(ch)) {
                        lowerCaseCount++;
                    } else if (Character.isUpperCase(ch)) {
                        upperCaseCount++;
                    }
                }

                System.out.println("数字字符数量: " + digitCount);
                System.out.println("小写字母字符数量: " + lowerCaseCount);
                System.out.println("大写字母字符数量: " + upperCaseCount);
            }

    public static void main2(String[] args) {

                String input = "asdq56wfhellohelloer8tyhellofbhelloy7jthellofyjunkjkhellort345hello";
                String subString = "hello";
                int count = 0;
                int index = 0;

                // 使用循环查找子字符串出现的次数
                while ((index = input.indexOf(subString, index)) != -1) {
                    count++;
                    index += subString.length(); // 移动到下一个位置
                }

                System.out.println("子字符串 \"" + subString + "\" 出现次数: " + count);
            }

    public static void main3(String[] args) {



                Scanner scanner = new Scanner(System.in);
                System.out.print("请输入用户名: ");
                String username = scanner.nextLine();
                System.out.print("请输入密码: ");
                String password = scanner.nextLine();

                if ("admin".equalsIgnoreCase(username) && "123".equals(password)) {
                    System.out.println("登录成功！");
                } else {
                    System.out.println("登录失败，用户名或密码错误！");
                }
                scanner.close();
            }

    public static void main4(String[] args) {

                String filePath = "d:/document/data/hello.jpg";
                String fileName = getFileName(filePath);
                String fileType = getFileType(fileName);
                System.out.println("文件名: " + fileName);
                System.out.println("文件类型: " + fileType);
            }

            private static String getFileName(String filePath) {
                int index = filePath.lastIndexOf('/');
                if (index == -1) {
                    index = filePath.lastIndexOf('\\'); // For Windows-style paths
                }
                return filePath.substring(index + 1);
            }

            private static String getFileType(String fileName) {
                int index = fileName.lastIndexOf('.');
                if (index != -1) {
                    return fileName.substring(index + 1);
                }
                return ""; // No file extension
            }

    public static void main(String[] args) {

                String original = "abcdefg";
                String reversed = reversePartOfString(original, 2, 5);
                System.out.println("反转后的字符串: " + reversed);
            }

            private static String reversePartOfString(String str, int start, int end) {
                if (str == null || start < 0 || end > str.length() || start > end) {
                    throw new IllegalArgumentException("无效的参数");
                }
                StringBuilder sb = new StringBuilder(str);
                sb.reverse().delete(0, str.length() - end).delete(end - start, str.length());
                return sb.reverse().insert(0, str.substring(0, start)).insert(start + (end - start), str.substring(end)).toString();
            }
}









